package org.example.validation;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.example.anno.State;

public class StateValidation implements ConstraintValidator<State,String> {

    /**
     *
     * @param value 将来要校验的数据
     * @param Context
     * @return  如果返回false，则校验不通过。如果返回true，则校验通过
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext Context) {
        //提供校验规则
        if (value == null){
            return false;
        }
        if (value.equals("快乐") || value.equals("浪漫") || value.equals("愤怒") || value.equals("不开心")){
            return true;
        }
        return false;
    }

}
